#include <iostream>

using namespace std;
#include <algorithm>
#include <vector>

class Solution
{
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * max increasing subsequence
     * @param arr int整型vector the array
     * @return int整型
     */
    int MLS(vector<int> &arr)
    {
        // write code here
        sort(arr.begin(), arr.end());
        int left = 0, right = 1;
        int len = -1;
        while (right < arr.size())
        {
            int count = 1;
        again:
            while (right < arr.size() && arr[right] - 1 == arr[right - 1])
            {
                right++;
                count++;
            }
            while (right < arr.size() && arr[right] == arr[right - 1])
                right++;
            if (arr[right] - 1 == arr[right - 1])
            {
                goto again;
            }
            len = max(len, count);
            left = right;
            right++;
        }

        return len;
    }
};